package module.edittroop.view.troopinfopanel
{
	import com.darwin.darwinUI.controls.IListItem;
	import com.darwin.darwinUI.core.UIComponent;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import module.building.model.dataObj.EquipObj;
	import module.edittroop.model.dataObj.ArmsConfigObj;
	import module.edittroop.model.dataObj.HeroConfigObj;
	import module.main.view.ResourceConst;

	/**
	 *用于设置listItem属性的一个类，通过部件的OBJ来设置
	 * @author jichang
	 * 
	 */	
	public class HeadFarem extends UIComponent implements IListItem
	{
		private var _headSprite:Sprite;
		public function HeadFarem()
		{
			super();
//			this.backgroundAuto = true;
//			this.backgroundSkin = "EditTroop." + ResourceConst.EDIT_TROOP_PICTURE_FRAME;
			this.height = 54.0;
			this.width = 53.0;
		}
		
		private var _selected:Boolean = false;
		public function set selected(v:Boolean):void
		{
			_selected = v;
		}
		
		public function get selected():Boolean
		{
			return _selected;
		}
		
		public function get data():Object
		{
			return _data;
		}
		private var _data:Object;
		public function set data(v:Object):void
		{
			_data = v;
			if(v is ArmsConfigObj)
			{
				addChild((v as ArmsConfigObj).getIcon(54,53));
			}
			else if (v is EquipObj)
			{
				addChild((v as EquipObj).getIcon(46,50));
			}
			else if(v is HeroConfigObj){
				var sprite:Sprite = (v as HeroConfigObj).getIcon(54);
				addChild(sprite);
			}
			else{
				this.backgroundSkin = "EditTroop." + ResourceConst.EDIT_TROOP_PICTURE_FRAME;
			}
		}
		
		private var _index:int;
		public function get index():int
		{
			return _index;
		}
		
		public function set index(v:int):void
		{
			_index = v;
		}
		
		public function dispose():void
		{
			if(this.parent)
			{
				this.parent.removeChild(this);
			}
		}
	}
}